package com.dyl.tets;

import com.dyl.entity.Student;
import com.dyl.service.StudentService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * 类名：
 * 作者：DYL
 * 功能：
 */
@SpringBootTest
public class TestMapper {
    @Autowired
    private StudentService studentService;

    // 1. 逻辑删除演示
    @Test
    public void test() {
        List<Student> list = studentService.list();
        list.forEach(System.out::println);
    }

    // 2. 演示自动填充功能 （插入功能演示，同时修改了create_time和update_time两个列）
    @Test
    public void test2() {
        Student student = new Student();
        student.setSname("林俊杰");
        student.setSex("男");
        student.setAge(18);
        student.setAddr("北京");
        student.setCid(1);
        studentService.save(student);

    }

    @Test // 2. 演示自动填充功能 （修改功能演示，修改了update_time）
    public void test3() {
        Integer sid = 18;
        Student student = studentService.getById(sid);
        student.setSname("林小杰");
        student.setAddr("中国台湾");
        studentService.updateById(student);
    }
}



